<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<title>Document</title>
	<style>
		.box{
			width: 80%;
			margin: auto;
			text-align: center;
		}
		label{
			display: block;
			margin-bottom: 10px;
		}
		input[type="number"]{
			outline: none;
			padding: 10px;
			width: 31%;
			border-radius: 10px;
			border: 1px solid #999;
		}
		input::-webkit-outer-spin-button,
		input::-webkit-inner-spin-button {
		    -webkit-appearance: none !important;
		    margin: 0;
		}
		input[type="button"]{
			outline: none;
			color: #fff;
			padding: 10px;
			border-radius: 10px;
			border: 1px solid #ee4040;
			background: #ee4040;
		}
		#text{
			color: #EE4040;
		}
	</style>
</head>
<body>
	<div class="box">
		<label>
			<input type="number" name="" id="phone" placeholder="请输入您的手机号" />
		</label>
		<label>
			<input style="width: 22.5%;" type="number" name="" id="yzm" placeholder="输入验证码" />
			<input type="button" id="verification" value="发送验证码" />
		</label>
		<label>
			<input style="width: 34%;margin-top: 10px;" type="button" name="" id="register" value="注册" />
		</label>
		<p id="text"></p>
	</div>
	
</body>
<script type="text/javascript" src="protopye.js" ></script>
<script>
	var	verification = document.getElementById('verification');
	var item = new itemFun();
	
	verification.onclick = function(){
		var item = new itemFun();
		var phone = document.getElementById('phone');
		var phoneVal = phone.value;
		message = "手机号码格式不正确";
		var num = item.random(6)
		if(item.isPhone(phoneVal)){
			//随机数
			alert(num)
			//保存随机数
			item.setCode(phoneVal,num)
			item.time()
		}else{
			alert(message)
		}
		
	}
	document.getElementById('register').onclick=function(){
		var item = new itemFun();
		var yzm = document.getElementById('yzm');
		var text = document.getElementById('text');
		var phone = document.getElementById('phone');
		var phoneVal = phone.value;
		if(item.getCode(phoneVal) != yzm.value){
			text.innerHTML = '验证码不正确';
			return false
		}
	}
</script>
</html>